﻿@using System.Web.Script.Serialization
@using KMF.WebUI.Areas.KMFadmin.Models
@using KMF.WebUI.Areas.KMFadmin.CustomHelpers
@model KMF.Common.ProviderDto
@{
    ViewBag.Title = "Edit";
    Layout = "~/Areas/KMFadmin/Views/Shared/_layout.cshtml";
    var jsSerializer = new JavaScriptSerializer();
    var errorInfo = jsSerializer.Serialize(TempData["updateInfo"] ?? -1);
}

@section LeftMenu
{
    <ul id="p-quick-menu" class="quick-menu">
        <li class="qmn-info-pro">Thông tin ncc</li>
    </ul>
}
<nav>
    <div id="jCrumbs" class="breadCrumb module">
        <ul>
            <li><a href="/Admin/"><i class="bootstrap icon-home"></i></a></li>
            <li><a href="@Url.Action("Index", "AdminProvider")">Danh sách ncc</a> </li>
            <li><a href="@Url.Action("Edit", "AdminProvider")">Sửa nhà cc</a> </li>
        </ul>
    </div>
</nav>
<div class="toolBox">
    @Html.ToolBox(new List<object> { new Edit() { ClassCss = "Save", ActionName = "Javascript:void(0)" }, new Delete() { ClassCss = "Del", ActionName = "/KMFadmin/DeleteProvider" }, new Back { ClassCss = "Back", ActionName = @Url.Action("Index", "AdminProvider") } })
</div>
@using (Html.BeginForm("Edit", "AdminProvider", FormMethod.Post, new { @class = "formAddCate", enctype = "multipart/form-data" }))
{
    <div class="box-Info">
        <div class="Info-header">
            <span>Sửa ncc </span>
        </div>
        <div class="error-info">
            @errorInfo
        </div>
        <div class="Info-body ib-infopro">

            <table cellpadding="0" cellspacing="0" width="100%" border="0" class="table-info">
                <tr>
                    <td class="tInfoLeft">Tên ncc
                    </td>
                    <td class="tInfoRight">
                        @Html.TextBoxFor(m => m.Name)
                        @Html.ValidationMessageFor(m => m.Name)
                    </td>
                </tr>
                <tr>
                    <td class="tInfoLeft">Mô tả
                    </td>
                    <td class="tInfoRight">
                        @Html.TextAreaFor(m => m.Description, new { @class = "cssAreaHeight" })
                        @Html.ValidationMessageFor(m => m.Description)
                    </td>
                </tr>
                <tr>
                    <td class="tInfoLeft">Ảnh đại diện
                    </td>
                    <td class="tInfoRight">
                        <input type="file" name="fileImagePath" />
                        @Html.HiddenFor(m => m.ImagePath, new { value = Model.ImagePath })<br/>
                        <img src="/upload/ProviderImages/@Model.ImagePath" width="45" height="45"/>
                    </td>
                </tr>
                <tr>
                    <td class="tInfoLeft">Thứ tự
                    </td>
                    <td class="tInfoRight">
                        @Html.TextBoxFor(m => m.Ordering, new { @class = "cssInputWidthSmall2" })
                    </td>
                </tr>
                <tr>
                    <td class="tInfoLeft">Hiển thị trang chủ
                    </td>
                    <td class="tInfoRight">
                       @Html.CheckBoxFor(m => m.ShowHome,new {@checked ="checked"})
                        
                        Nổi bật
                        @Html.CheckBoxFor(m => m.Hot)
                    </td>
                </tr>
            </table>

        </div>
    </div>

}
@section scripts
{
    <script type="text/javascript">
        $(function () {
            SubmitFormUseToolBox($('#Toolbox li.Add a'), $('form'));
            $('ul li.Save a').click(function () {
                $('form').submit();
            });
            var errorInfo = @errorInfo;
            if(errorInfo == 0) {
                $('.error-info').text('Cập nhật thông tin không thành công, đã có lỗi xảy ra!');
            }
            else if(errorInfo == 1) {
                $('.error-info').text('Cập nhật thông tin thành công!');
            } else{
                $('.error-info').text('');
            }
        });
    </script>
}
